//
//  WebViewController.m
//  QinRen
//
//  Created by Easaa on 15/9/12.
//  Copyright (c) 2015年 Donny. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()<UIWebViewDelegate>

@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self creatUI];
}

-(void)creatUI
{
    UIWebView *web = [[UIWebView alloc]initWithFrame:self.view.bounds];
   NSURLRequest *requesr =  [NSURLRequest requestWithURL:[NSURL URLWithString:_webContent]];
    web.delegate = self;
    [web loadRequest:requesr];
    [self.view addSubview:web];
}
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    if(navigationType == UIWebViewNavigationTypeLinkClicked )
    {
        NSString *url =[NSString stringWithFormat:@"%@",request.URL];
        
        NSString *method = [url substringFromIndex:6];
        
        NSString *encodingString = [method stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        
//        SearchViewController *searchVc = [[SearchViewController alloc]init];
//        searchVc.name = encodingString;
//        [self.navigationController pushViewController:searchVc animated:YES];
        
        DLog(@"%@",request.URL.absoluteString);
        
    }
    return YES;
}
@end
